<?php

namespace app\api\exception;


use think\Exception;
use think\facade\Lang;

class BaseException extends Exception
{
    public $statusCode = 200;
    public $message = 'service.errorMessage';
    public $code = 1;

    public function __construct($params = [])
    {
        if(!is_array($params)){
            throw new Exception(Lang::get('service.notAnArray'));
        }

        if(array_key_exists('statusCode',$params)){
            $this->statusCode = $params['statusCode'];
        }

        if(array_key_exists('code',$params)){
            $this->code = $params['code'];
        }

        if(array_key_exists('message',$params)){
            $this->message = $params['message'];
        }

    }
}